//---------------------------------------------------------------------------

#ifndef CIISNetInterfaceH
#define CIISNetInterfaceH

#include "CIISNetInterface.h"
#include "CIISDB.h"
#include "DebugWinU.h"
#include "USBCANInterface.h"
#include "CIISMonitor.h"
#include "CIISLPR.h"
#include "CIISDecay.h"
#include "CIISUpdatePS.h"

//---------------------------------------------------------------------------


class TCIISNetInterface : public TObject
{
private:
  TCIISDBModule *DB;
  TDebugWin *DW;
  String Ctrl;
  TUSBCANInterface *CAN;
  TList *Monitors;
  TList *Decays;
	TList *LPRs;
	TList *UPSs;

  TTimer *TimerCapabilityReq, *TimerSetCANGroup, *TimerIShuntReq, *TimerVerReq,
         *TimerUpdateAlarm, *TimerRestart, *TimerSClock, *TimerUpdatePS;

  int CapReqCounter;
  TDateTime  ScheduleDateTime, SClockNextEvent, SClockStart;
	int ScheduleStatus, SClockEvent;
  int TSys;
  bool CIINetConnected;
  TLocateOptions NoOpts;

  void __fastcall SendAccept(Cardinal SerNo, Word CANAdr);
  void __fastcall Debug(String Message);
  void __fastcall RequestCapability(Word CanAdr);
  void __fastcall SetGroup(Word CanAdr, Word CanGroup);
  void __fastcall RequestIShunt(Word CanAdr);
  void __fastcall RequestRShunt(Word CanAdr);
  void __fastcall RequestVer(Word CanAdr);
  void __fastcall SendClrLPR(Word CanAdr);
  void __fastcall WatchLPRStatus(int ZoneNo);

protected:

public:
      __fastcall TCIISNetInterface(TCIISDBModule *SetDB,
                                        TDebugWin *SetDebugWin,
                                        String SetCtrl);
       __fastcall ~TCIISNetInterface();
  void __fastcall SetDebugWin(TDebugWin *SetDebugWin);
  void __fastcall ProcessMessage(const Byte *CANInMsg);
  void __fastcall RestartCanNet();
  bool __fastcall UpdateCurrentPS();
  bool __fastcall StartMonitor(int ZoneNo, bool ReStart);
  bool __fastcall StopRecording(int ZoneNo);
  bool __fastcall ResetCanNet();
  bool __fastcall UpdateLastValue(int ZoneNo, int NodeSerialNo);
  bool __fastcall UpdateAlarms();
  bool __fastcall StartLPR(int ZoneNo);
  bool __fastcall StartDecay(int ZoneNo);
  Word __fastcall GetCanAdr();
	void __fastcall TimerSClockEvent(TObject * Sender);
  bool __fastcall MoveSensor(int SerialNo);
  bool __fastcall MovePS(int SerialNo);
	bool __fastcall UpdateScheduleDateTime();
  bool __fastcall Connected();

__published:
	void __fastcall TimerUpdateAlarmsEvent(TObject *Sender);
  void __fastcall TimerCapabilityReqEvent(TObject *Sender);
  void __fastcall TimerSetCANGroupEvent(TObject *Sender);
	void __fastcall TimerIShuntReqEvent(TObject *Sender);
	void __fastcall TimerVerReqEvent(TObject *Sender);
	void __fastcall TimerRestartEvent(TObject *Sender);
	void __fastcall TimerUpdatePSEvent(TObject *Sender);

};

#endif
